package customer.zspt.cn.customer.utils;
import android.os.Environment;
import android.util.Log;

import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;

import java.io.File;

/**
 * Created by Administrator on 2018/7/29 0029.
 */
public class DownLoadImageSaveUtils {
    public static String path = Environment.getExternalStorageDirectory().getAbsolutePath()
            +File.separator+"customer"+File.separator;
    public static void setImageUrl(String url,long tempstap)
    {
        HttpUtils utils = new HttpUtils();
        File file = new File(path);
        if(!file.exists())
        {
            file.mkdirs();
        }
        String imagePath = path + tempstap+".png";
        utils.download(url,imagePath, new RequestCallBack<File>() {
            @Override
            public void onSuccess(ResponseInfo<File> responseInfo) {

            }
            @Override
            public void onFailure(HttpException e, String s) {

            }
            @Override
            public void onLoading(long total, long current, boolean isUploading) {
                Log.e("进度",total+"   current="+current);
                super.onLoading(total, current, isUploading);
            }
        });
    }
    public static String getImageBit(long tempstap)
    {
          String imageUrl = path + tempstap+".png";
          File file = new File(imageUrl);
           if(file!=null)
           {
               return file.getPath();
           }
          return null;
    }
}
